//
//  LYTuiJianModel.m
//  开心一刻
//
//  Created by lanou on 16/4/7.
//  Copyright © 2016年 刘洋. All rights reserved.
//

#import "LYTuiJianModel.h"
@implementation LYTuiJianModel
+ (NSMutableArray *)getData : (NSDictionary *)dic
{
    NSMutableArray * arrayA = [NSMutableArray array];
    NSDictionary * dataDic= dic[@"data"];
    NSArray * dataArray = dataDic [@"data"];
    for (NSDictionary * two in dataArray)
    {
        LYTuiJianModel * model = [[LYTuiJianModel alloc]init];
        NSArray * array = two[@"comments"];
        if (array.count != 0)
        {NSDictionary * comentDic = array[0];
            [model setValuesForKeysWithDictionary:comentDic];

        }
        
        NSDictionary * photoDic = two[@"group"];
        model.title = photoDic[@"text"];
        model.share_url = photoDic[@"share_url"];
        model.category_name = photoDic[@"category_name"];
        NSDictionary * myName = photoDic[@"user"];
        model.name = myName[@"name"];
        model.zuozhe = myName[@"avatar_url"];
        model.mp4_url = photoDic[@"mp4_url"];
        // 一张图片的
        NSDictionary *  phot = photoDic[@"large_image"];
        if (phot != nil)
        {
            [model setValuesForKeysWithDictionary:phot];
            NSArray * lageImageArray = phot[@"url_list"];
            NSDictionary * ii = lageImageArray[0];
            model.url = ii[@"url"];
        }
        else
        {
            NSArray * myArrayOne = photoDic[@"large_image_list"];
            if (myArrayOne != nil)
            {
                model.photoArray = [NSMutableArray array];
                NSDictionary * one = myArrayOne[0];
            [model setValuesForKeysWithDictionary:one];
                for (NSDictionary * oo in myArrayOne)
                {
                    
                    NSArray * pp = oo[@"url_list"];
                    NSDictionary * dicoo = pp[0];
                    [model.photoArray addObject:dicoo[@"url"]];
                }
            }
            else
            {
                model.isMovie = YES;
                //NSDictionary * movie = photoDic[@"gifvideo"];
                
                NSDictionary * dicx = photoDic[@"720p_video"];
                [model setValuesForKeysWithDictionary:dicx];
                NSArray * ppw = dicx[@"url_list"];
                NSDictionary * iii = ppw[0];
                model.url = iii[@"url"];
                NSDictionary * dicv = photoDic[@"large_cover"];
                NSArray *ppp = dicv[@"url_list"];
                NSDictionary * aaaaa = ppp[0];
                model.coverImage = aaaaa[@"url"];
           
            }
    
    
        }
        if (model.title == nil)
        {
            
        }
        else
        {
        [arrayA addObject:model];
        }
    }
    
    return arrayA;
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    
}

@end
